package org.groovymud.object.registry.persistence;

import java.io.InputStream;
import java.io.OutputStream;

public interface MudDataSource<T> {

	public void serialize(T object, OutputStream out);

	public T deserializeObject(InputStream xmlIn);

	/**
	 * Loads an object from a datasource, using the given object handle. 
	 *
	 * The object handle could be a file name or id, and implementations will
	 * guarentee to load the object saved with "equal" handles. 
	 * 
	 * @param objectHandle
	 * @return
	 * @throws DataSourceException
	 */
	public T loadObject(String objectHandle) throws DataSourceException;

	/**
	 * saves a particular object to the data store, using the object handle
	 * provided. 
	 * 
	 * Object handles saved should correlate with the loadObject method's 
	 * handle when loading.
	 * 
	 * @param objectHandle
	 * @param object
	 * @throws DataSourceException
	 */
	public void saveObject(String objectHandle, T object) throws DataSourceException;

	public boolean deleteObject(String objectHandle);
}
